﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace vAddins
{
    public enum RequirementType
    {
        Addin
    }

    public class Requirement
    {
        public RequirementType Type { get; private set; }

        public string Path { get; private set; }

        internal Requirement(RequirementType type, string path)
        {
            Type = type;
            Path = path;
        }

        internal Requirement(XmlNode e)
        {
            switch (e.Name)
            {
                case "AddinRequirement":
                    if (e.Attributes.Count != 1 || e.Attributes["name"] == null) throw new XmlException("All nodes within the \"Requirements\" node must only have a \"name\" attribute.\r\nPlease look at the example manifest file in the vAddins assembly!");

                    //References.Add(new Reference(ReferenceType.System, e.Attributes["path"].Value));
                    break;
                default:
                    throw new XmlException("Invalid tag identified within the vAddin's Requirements node.\r\nPlease look at the example manifest file in the vAddins assembly!");
            }
        }
    }



    public class VersionRule
    {
        internal VersionRule(XmlNode e)
        {
            switch (e.Name)
            {
                case "Rule": break;
                default: throw new XmlException("Invalid tag identified within an AddinRequirement node.\r\nPlease look at the example manifest file in the vAddins assembly!");
            }
        }
    }
}
